import 'package:cached_network_image/cached_network_image.dart';
import 'package:casdon/modules/recipe/data/model/recipe_module_content_model.dart';
import 'package:casdon/modules/recipe/data/model/recipe_placeholder_data.dart';
import 'package:casdon/modules/recipe/ui/widgets/play_orverlay_button.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

/// 活动位（style == 3， showstyle == 2）
class RecipeCardStyle3Showstyle2 extends StatelessWidget {
  final RecipeModuleContentModel item;

  const RecipeCardStyle3Showstyle2({required this.item});

  @override
  Widget build(BuildContext context) {
    return Container(
      margin: EdgeInsets.only(right: 12.w),
      width: MediaQuery.of(context).size.width / 2.3,
      child: Column(
        mainAxisAlignment: MainAxisAlignment.start,
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          /// 图片部分
          SizedBox(
            width: double.infinity,
            height: 100.h,
            child: ClipRRect(
              borderRadius: BorderRadius.circular(8),
              child: Stack(
                fit: StackFit.expand,
                children: [
                  CachedNetworkImage(
                    imageUrl: item.imgUrl,
                    cacheKey: item.id,
                    fit: BoxFit.cover,
                    fadeInDuration: Duration.zero,
                    placeholder: (context, url) => const SizedBox(),
                    errorWidget: (context, url, error) {
                      return Image.network(
                        recipePlaceHolderImgUrl,
                        fit: BoxFit.cover,
                        errorBuilder: (context, error, stackTrace) {
                          return Container(
                            color: Colors.grey[200],
                            child: const Icon(Icons.image_outlined, color: Colors.grey),
                          );
                        },
                      );
                    },
                  ),
                  if (item.isVideo) const PlayOverlayButton(),
                ],
              ),
            ),
          ),
        ],
      ),
    );
  }
}
